package com.sand.ExceptionHandler;

import com.sand.Exception.SandException;
import com.sand.result.ResponseResult;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@Slf4j
@ControllerAdvice
public class SandUserExceptionHandler {


    @ExceptionHandler(value = SandException.class)
    @ResponseBody
    public ResponseResult<String> SandHandler(HttpServletRequest req, SandException e){

        log.info("发生业务错误信息是{}",e.getMessage());

        return new ResponseResult<String>().errorResult(e.getCode(),e.getMessage());
    }



}
